package com.avic.map.common.convertor;


import com.avic.map.common.constant.AppConstant;
import com.avic.map.controller.info.CarResourceListInfo;
import com.avic.map.dal.model.CarResource;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 车辆资源对象转换器
 */
public class CarResourceConvertor {

    /**
     * 将 pageSystemUser 转换为 SystemUserInfo
     *
     * @author: huangsheng
     * @date: 2017/10/20 下午2:00
     */
    public static List<CarResourceListInfo> CarResourcesToCarResourceListInfo(List<CarResource> carResources, String visitPre) {
        if (null != carResources && carResources.size() > 0) {
            List<CarResourceListInfo> carResourceListInfos = new ArrayList<>();
            carResources.forEach(carResource -> {
                CarResourceListInfo carResourceListInfo = new CarResourceListInfo();
                carResourceListInfo.setDriveForm(carResource.getDriveForm());
                carResourceListInfo.setFoamFireExtinguisherModel(carResource.getFoamFireExtinguisherModel());
                carResourceListInfo.setChassisModel(carResource.getChassisModel());
                carResourceListInfo.setSelfWeight(carResource.getSelfWeight());
                carResourceListInfo.setBoomModel(carResource.getBoomModel());
                carResourceListInfo.setCarWater(carResource.getCarWater());
                carResourceListInfo.setPullArmHookModel(carResource.getPullArmHookModel());
                carResourceListInfo.setCarFoam(carResource.getCarFoam());
                carResourceListInfo.setCarCrew(carResource.getCarCrew());
                carResourceListInfo.setCarDimensions(carResource.getCarDimensions());
                carResourceListInfo.setPumpModel(carResource.getPumpModel());
                carResourceListInfo.setPumpFlow(carResource.getPumpFlow());
                carResourceListInfo.setWaterAbsorptionFlow(carResource.getWaterAbsorptionFlow());
                carResourceListInfo.setWaterCannonModel(carResource.getWaterCannonModel());
                carResourceListInfo.setWaterSupply(carResource.getWaterSupply());
                carResourceListInfo.setWaterCannonFlow(carResource.getWaterCannonFlow());
                carResourceListInfo.setLoadingWaterVolume(carResource.getLoadingWaterVolume());
                carResourceListInfo.setCarRange(carResource.getCarRange());
                carResourceListInfo.setCarRemark(carResource.getCarRemark());
                carResourceListInfo.setId(carResource.getId());
                carResourceListInfo.setCarNumber(carResource.getCarNumber());
                carResourceListInfo.setFleetId(StringUtils.isNotBlank(carResource.getFleetId()) ? carResource.getFleetId() : StringUtils.EMPTY);
                carResourceListInfo.setFleetName(StringUtils.isNotBlank(carResource.getFleetName()) ? carResource.getFleetName() : StringUtils.EMPTY);
                carResourceListInfo.setCarType(carResource.getCarType());
                carResourceListInfo.setCreateTime(StringUtils.isNotBlank(carResource.getCreateTime()) ?
                        StringUtils.substringBefore(carResource.getCreateTime(), AppConstant.MYBATIS_DATA_TIME_SEPARATOR) : StringUtils.EMPTY);
                carResourceListInfo.setCarImagePath(StringUtils.isNotBlank(carResource.getCarImagePath()) ?
                        visitPre + carResource.getCarImagePath() : StringUtils.EMPTY);
                carResourceListInfos.add(carResourceListInfo);
            });
            return carResourceListInfos;
        }
        return new ArrayList<>();
    }
}
